<?php

	class YouTubeUtils
	{
		const YOU_YUBE_KEY_PATTERN = '/v=([^&]+)/';

		/**
		 * Returns you tube video code by link to video.
		 * 
		 * @param string $youTubeLink
		 * @return string
		 */
		public static function getYouTubeCode($youTubeLink)
		{
			preg_match_all(self::YOU_YUBE_KEY_PATTERN, $youTubeLink, $matches);
			if (isset($matches[1]) && isset($matches[1][0]))
			{
				return $matches[1][0];
			}
			return '';
		}
	}